PPP : Point to point networking

更新时间:
2024-05-15
下载文档

PPP : Point to point networking

This module provides point-to-point dial-up network connection function. Supports PPPoS and PPPoE connection capabilities. PPPoL2TP connection support will be provided in the future.

PPP connection status can be obtained using the Ifevent module.

User can use the following code to import the ppp module.

var ppp = require('router/ppp');

Support

The following shows ppp module APIs available for each permissions.

 User ModePrivilege Mode
ppp.create 
ppp.tunnel 
ppp.delete 
ppp.connect 
ppp.disconnect 
ppp.phase 

PPP Object

ppp.create(type, ttyName[, ttyHwOpt])

  • type {Integer} Connection type, must be ppp.PPPoS.
  • ttyName {String} Specifies the tty device name.
  • ttyHwOpt {Object} Tty device hardware options, without this parameter, the hardware options of the tty device are not set.
  • Returns: {String} PPP connection network interface name.

The hardware option is an object with following members:

  • baud {Integer} Baudrate.
  • data {Integer} Data bits, 5 ~ 8 bits.
  • stop {Integer} Stop bits, 1 ~ 2 bits.
  • parity {String} Parity, 'odd', 'even' or 'none'.

Example

var ifname1 = ppp.create(ppp.PPPoS, '/dev/ttyS2');
var ifname2 = ppp.create(ppp.PPPoS, '/dev/ttyS3', 
{ baud: 115200 });

ppp.create(type, ethIfname)

  • type {Integer} Connection type, must be ppp.PPPoE.
  • ethIfname {String} Specifies the ethernet ifname.
  • Returns: {String} PPP connection network interface name.

Example

var ifname = ppp.create(ppp.PPPoE, 'en1');

ppp.tunnel(server[, port[, seckey]])

  • server {String} L2TP server IPv4 address.
  • port {Integer} Server port. default: 1701.
  • seckey {String} Preset security key. default: undefined.

Example

var ifname = ppp.tunnel('192.168.1.3', 1701);

Create an L2TP tunnel.

ppp.delete(ifname)

  • ifname {String} PPP connection network interface name.
  • Returns: {Boolean} Whether the operation was successful.

Delete a PPP network interface. You must ensure that the phase of this network interface is ppp.PHASE_DEAD before it can be deleted.

Example

ppp.delete('pp6');

ppp.connect(ifname, [user[, passwd]])

  • ifname {String} PPP connection network interface name.
  • user {String} User name. default: undefined.
  • passwd {String} Password. default: undefined.
  • Returns: {Boolean} Whether this interface starts to dial.

Use the specified PPP network interface to start dialing. This method only initiates dialing. The connection status change can be monitored using the Ifevent module.

Example

var ifname = ppp.create(ppp.PPPoE, 'en1');
ppp.connect(ifname, 'user', 'pass');

ppp.disconnect(ifname[, force])

  • ifname {String} PPP connection network interface name.
  • force {Boolean} Whether to force close. default: false.
  • Returns: {Boolean} Whether the operation was successful.

ppp.phase(ifname)

  • ifname {String} PPP connection network interface name.
  • Returns: {Integer} PPP network interface current phase.

Get the PPP connection network interface current phase. the return value must be one of the following:

  • ppp.PHASE_DEAD
  • ppp.PHASE_MASTER
  • ppp.PHASE_HOLDOFF
  • ppp.PHASE_INITIALIZE
  • ppp.PHASE_SERIALCONN
  • ppp.PHASE_DORMANT
  • ppp.PHASE_ESTABLISH
  • ppp.PHASE_AUTHENTICATE
  • ppp.PHASE_CALLBACK
  • ppp.PHASE_NETWORK
  • ppp.PHASE_RUNNING
  • ppp.PHASE_TERMINATE
  • ppp.PHASE_DISCONNECT
文档内容是否对您有所帮助?
有帮助
没帮助